package com.aqmh.middleware.whitelist.controller;

import com.aqmh.middleware.whitelist.annotation.DoWhiteList;
import com.aqmh.middleware.whitelist.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类描述:
 *
 * @author LiLiDong
 * @menu 白名单测试模块
 * @date 2023/5/2 11:21
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 通过：http://localhost:8083/user/api/queryUserInfo?userId=lld
     * 拦截：http://localhost:8083/user/api/queryUserInfo?userId=123
     */
    @DoWhiteList(key = "userId", returnJson = "{\"code\":\"30002\",\"info\":\"非白名单可访问用户,被拦截！\"}")
    @RequestMapping(path = "/api/queryUserInfo", method = RequestMethod.GET)
    public UserInfo queryUserInfo(@RequestParam String userId) {
        log.info("查询用户信息，userId：{}", userId);
        return new UserInfo("安前码后:" + userId, 18, "深圳市南山区-35-6000");
    }
}
